package biz;

import dao.TypetbDAO;
import entity.TypetbEntity;

import java.sql.SQLException;
import java.util.List;

/*
 * @Description：
 *       类型表数据处理
 * @Author: JiangFan
 * @Date: 2019/3/8
 * @Time：16:47
 */
public class TypeBiz {
    TypetbDAO td=new TypetbDAO ();
    /** 添加尺寸
     * @param te ce由servlet中获取
     * @return
     * @throws SQLException
     * @throws ClassNotFoundException
     */
    public int addType (TypetbEntity te) throws SQLException, ClassNotFoundException {
        TypetbEntity c=td.selectTypeOne (te.getType_id ());
        return c==null?td.insertType (te):0;
    }

    /**查询所有尺寸信息
     * @return 返回到List集合
     */
    public List<TypetbEntity> queryTypeAll ()
            throws ClassNotFoundException, SQLException, InstantiationException, IllegalAccessException {
        return td.selectTypeAll ();
    }

    /** 查询尺寸是否可用
     * @param type_name
     * @return 返回true表示尺寸不存在
     * @throws SQLException
     * @throws ClassNotFoundException
     */
    public boolean checkType(String type_name) throws SQLException, ClassNotFoundException {
        return td.selectTypeOne (type_name)==null;
    }
}
